﻿using Coldairarrow.Business.Base;
using Coldairarrow.Entity.Base;
using Coldairarrow.Entity.DTO;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Coldairarrow.Api.Controllers.Base
{
    [Route("/Base/[controller]/[action]")]
    public class Base_RepairOrderAccidentController : BaseApiController
    {
        #region DI

        public Base_RepairOrderAccidentController(IBase_RepairOrderAccidentBusiness base_RepairOrderAccidentBus)
        {
            _base_RepairOrderAccidentBus = base_RepairOrderAccidentBus;
        }

        IBase_RepairOrderAccidentBusiness _base_RepairOrderAccidentBus { get; }

        #endregion

        #region 获取

        [HttpPost]
        public async Task<PageResult<Base_RepairOrderAccident>> GetDataList(PageInput<ConditionDTO> input)
        {
            return await _base_RepairOrderAccidentBus.GetDataListAsync(input);
        }

        [HttpPost]
        public async Task<Base_RepairOrderAccident> GetTheData(IdInputDTO input)
        {
            return await _base_RepairOrderAccidentBus.GetTheDataAsync(input.id);
        }
        /// <summary>
        /// pc获取设备事故列表
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PageResult<Base_RepairOrderAccidentDTO>> GetRepairOrderApplyList(PageInput<PB_ScheduleDetailConditionDTO> input) {
            return await _base_RepairOrderAccidentBus.GetRepairOrderApplyList(input);    
        }

        /// <summary>
        /// 获取设备规格
        /// </summary>
        /// <param name="DeviceId"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Base_RepairOrderAccidentSpec> GetRepairOrderAccidentSpec(string DeviceId) {
            return await _base_RepairOrderAccidentBus.GetRepairOrderAccidentSpec(DeviceId);
        }
        /// <summary>
        /// 通过设备编号获取设备事故记录
        /// </summary>
        /// <param name="input"></param>
        /// <param name="DeviceId"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PageResult<Base_RepairOrderAccidentDTO>> GetRepairDeviceId(PageInput<PB_ScheduleDetailConditionDTO> input, string DeviceId) {
            var listData = await _base_RepairOrderAccidentBus.GetRepairDeviceId(input,DeviceId);
            return listData;
        }
        #endregion

        #region 提交

        [HttpPost]
        public async Task SaveData(Base_RepairOrderAccident data)
        {
            if (data.Id.IsNullOrEmpty())
            {
                InitEntity(data);

                await _base_RepairOrderAccidentBus.AddDataAsync(data);
            }
            else
            {
                await _base_RepairOrderAccidentBus.UpdateDataAsync(data);
            }
        }

        [HttpPost]
        public async Task DeleteData(List<string> ids)
        {
            await _base_RepairOrderAccidentBus.DeleteDataAsync(ids);
        }

        #endregion
    }
}